<?php


namespace App\Models;


use Illuminate\Auth\Authenticatable as BaseAuthenticatable;
use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Laravel\Passport\HasApiTokens;
use Modules\Admin\Entities\Admin;
use Modules\Member\Entities\User;
use Spatie\Permission\Traits\HasRoles;

/**
 * App\Models\Authenticatable
 *
 * @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Client[]             $clients
 * @property-read int|null                                                                        $clients_count
 * @property-read mixed                                                                           $created_at
 * @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Permission[] $permissions
 * @property-read int|null                                                                        $permissions_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[]       $roles
 * @property-read int|null                                                                        $roles_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Token[]              $tokens
 * @property-read int|null                                                                        $tokens_count
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel createdAtAfter($date)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel createdAtBefore($date)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel createdAtBetween($start, $end)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel createdAtOfDay($data)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel lastLoginTimeAfter($date)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel lastLoginTimeBefore($date)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel lastLoginTimeBetween($start, $end)
 * @method static \Illuminate\Database\Eloquent\Builder|Authenticatable newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Authenticatable newQuery()
 * @method static \Illuminate\Database\Query\Builder|Authenticatable onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|Authenticatable permission($permissions)
 * @method static \Illuminate\Database\Eloquent\Builder|Authenticatable query()
 * @method static \Illuminate\Database\Eloquent\Builder|Authenticatable role($roles, $guard = null)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel updatedAtAfter($date)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel updatedAtBefore($date)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel updatedAtBetween($start, $end)
 * @method static \Illuminate\Database\Query\Builder|Authenticatable withTrashed()
 * @method static \Illuminate\Database\Query\Builder|Authenticatable withoutTrashed()
 * @mixin \Eloquent
 * @property-read \Illuminate\Database\Eloquent\Collection|\Modules\Log\Entities\Activity[]       $activities
 * @property-read int|null                                                                        $activities_count
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel sizeAfter($data)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel sizeBefore($data)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel sizeBetween($start, $end)
 */
class Authenticatable extends BaseModel implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
    use BaseAuthenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
    use HasRoles;
    use HasApiTokens;
    use SoftDeletes;

    public function isAdmin()
    {
        return $this instanceof Admin;
    }

    public function isUser()
    {
        return $this instanceof User;
    }
}
